﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    
    class DbHelper
    {
        
        private static readonly string conString = "server=.;database=Register;uid=sa;pwd=123456";
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            connection.Open();
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,conString);
            DataTable dt = new DataTable();
            dataAdapter.Fill(dt);
            return dt;
        }
        public static int AddOrDeleteOrEdittOrSave(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            connection.Open();
            SqlCommand command = new SqlCommand(sql,connection);
            return command.ExecuteNonQuery();
        
        }

    }
}
